home *** CD-ROM | disk | FTP | other *** search
- /* TextEditManager.h */
- /*
- * TextEditManager.h
- * Copyright © 1993 Apple Computer Inc. All rights reserved.
- *
- * These functions manage a TextEdit field (comparable to an EditText item in a
- * dialog. This module is intentionally more-or-less self-contained so it can
- * easily be exported to other applications. It is extremely limited: it does
- * not support styles, scrolling, or other niceties. It does, however, support
- * Undo.
- */
- #ifndef __TextEditManager__
- #define __TextEditManager__
- #ifndef THINK_C /* MPW includes */
- #include <Errors.h>
- #include <Script.h>
- #include <Types.h>
- #include <Resources.h>
- #include <QuickDraw.h>
- #include <Fonts.h>
- #include <Events.h>
- #include <Windows.h>
- #include <ToolUtils.h>
- #include <Memory.h>
- #include <TextEdit.h>
- #endif
- /*
- * Usage:
- * EditHandle CreateEditHandle(
- * const Rect *viewRect,
- * short fontNumber,
- * short fontSize,
- * short editMenuID,
- * short undoTextResID,
- * void *refCon
- * );
- * Create a TextEdit record. Return NULL on problems. The Handle returned
- * locates a private structure that will contain the TextEdit handle and
- * some information needed to support Undo. Applications access the
- * actual TextEdit handle by calling GetTEHandle(theEditHandle). The
- * undoTextResID is the id of a 'STR#' resource with the following text:
- * Undo
- * UndoTyping
- * UndoCut
- * UndoCopy
- * UndoPaste
- * UndoClear
- * RedoTyping
- * RedoCut
- * RedoCopy
- * RedoPaste
- * RedoClear
- *
- * void DisposeEditHandle(
- * EditHandle editHandle
- * );
- * Dispose of the TextEdit handle and all of the auxiliary structures.
- *
- * The application calls the following routines as necessary, passing the
- * result of GetTEHandle.
- * TEActivate Activate the TextEdit Record
- * TEDeactivate Deactivate the TextEdit Record
- * TEGetText, etc. Manipulate the text as needed. Note: cut, copy,
- * paste, and the various insert operations must be handled
- * by EditHandle functions in order to support Undo. DoEditEvent
- * does as much of this as possible.
- *
- * Boolean DoTextEditEvent(
- * EditHandle editHandle,
- * const EventRecord *eventRecord
- * );
- * Called on any event (even null events). It returns TRUE if it processed the
- * event: mouseDown (in the TextEdit viewRect), keyDown.
- *
- * Boolean AdjustEditMenu(
- * EditHandle editHandle
- * );
- * Called to setup the edit menu. It must have the standard item structure:
- * "Undo;(-;Cut;Copy;Paste;(-;Clear"
- * Returns TRUE if this text edit item was active. Otherwise, it does nothing.
- *
- * void RepositionEditItem(
- * EditHandle editHandle,
- * const Rect *viewRect
- * );
- * Called to move and resize the EditHandle datum. Called after the window is
- * redecorated.
- * Boolean ManageEditMenu(
- * EditHandle editHandle,
- * short menuItem
- * );
- * Called when an Edit Menu item is selected. Returns TRUE if this edit
- * menu item was active, otherwise, it does nothing. This function performs
- * Cut/Copy/Paste/Clear and Undo actions.
- */
-
-
- /*
- * The order of the following must track the order of the Undo text STR#
- */
- typedef enum UndoAction {
- kUndoUnknown = 0,
- kUndoByItself,
- kUndoTyping,
- kUndoCut,
- kUndoCopy,
- kUndoPaste,
- kUndoClear,
- kRedoTyping,
- kRedoCut,
- kRedoCopy,
- kRedoPaste,
- kRedoClear,
- kUndoOffset = (kRedoTyping - kUndoTyping)
- } UndoAction;
-
- typedef struct EditRecord {
- TEHandle teHandle; /* User's TextEdit handle */
- Handle undoHandle; /* Undone stuff stored here */
- unsigned short undoSelStart; /* SelStart of undone stuff */
- unsigned short undoSelEnd; /* SelEnd of undone stuff */
- Boolean newUndo; /* TRUE to start a sequence */
- short editMenuID; /* The Edit Menu ID */
- short undoTextResID; /* The Undo 'STR#' resource id */
- UndoAction undoAction; /* What is to be undone */
- void *refCon; /* At the app's disposal */
- } EditRecord, *EditPtr, **EditHandle;
-
-
- EditHandle CreateEditHandle(
- const Rect *viewRect,
- short fontNumber,
- short fontSize,
- short editMenuID,
- short undoTextResID,
- void *refCon
- );
- void DisposeEditHandle(
- EditHandle editHandle
- );
- Boolean DoTextEditEvent(
- EditHandle editHandle,
- const EventRecord *eventRecord
- );
-
- Boolean AdjustEditMenu(
- EditHandle editHandle
- );
- Boolean ManageEditMenu(
- EditHandle editHandle,
- short menuItem /* 1 = Undo, 3 = Cut, etc. */
- );
- void RepositionEditItem(
- EditHandle editHandle,
- const Rect *viewRect
- );
- #define GetTEHandle(editHandle) ((**(editHandle)).teHandle)
- #endif /* __TextEditManager__ */
-
-
-
-